# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Script.V1.Api.Processes do
  @moduledoc """
  API calls for all endpoints tagged `Processes`.
  """

  alias GoogleApi.Script.V1.Connection
  alias GoogleApi.Gax.{Request, Response}

  @library_version Mix.Project.config() |> Keyword.get(:version, "")

  @doc """
  List information about processes made by or on behalf of a user, such as process type and current status.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.Script.V1.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:pageSize` (*type:* `integer()`) - The maximum number of returned processes per page of results. Defaults to 50.
      *   `:pageToken` (*type:* `String.t`) - The token for continuing a previous list request on the next page. This should be set to the value of `nextPageToken` from a previous response.
      *   `:"userProcessFilter.deploymentId"` (*type:* `String.t`) - Optional field used to limit returned processes to those originating from projects with a specific deployment ID.
      *   `:"userProcessFilter.endTime"` (*type:* `DateTime.t`) - Optional field used to limit returned processes to those that completed on or before the given timestamp.
      *   `:"userProcessFilter.functionName"` (*type:* `String.t`) - Optional field used to limit returned processes to those originating from a script function with the given function name.
      *   `:"userProcessFilter.projectName"` (*type:* `String.t`) - Optional field used to limit returned processes to those originating from projects with project names containing a specific string.
      *   `:"userProcessFilter.scriptId"` (*type:* `String.t`) - Optional field used to limit returned processes to those originating from projects with a specific script ID.
      *   `:"userProcessFilter.startTime"` (*type:* `DateTime.t`) - Optional field used to limit returned processes to those that were started on or after the given timestamp.
      *   `:"userProcessFilter.statuses"` (*type:* `list(String.t)`) - Optional field used to limit returned processes to those having one of the specified process statuses.
      *   `:"userProcessFilter.types"` (*type:* `list(String.t)`) - Optional field used to limit returned processes to those having one of the specified process types.
      *   `:"userProcessFilter.userAccessLevels"` (*type:* `list(String.t)`) - Optional field used to limit returned processes to those having one of the specified user access levels.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.Script.V1.Model.ListUserProcessesResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec script_processes_list(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.Script.V1.Model.ListUserProcessesResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def script_processes_list(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :pageSize => :query,
      :pageToken => :query,
      :"userProcessFilter.deploymentId" => :query,
      :"userProcessFilter.endTime" => :query,
      :"userProcessFilter.functionName" => :query,
      :"userProcessFilter.projectName" => :query,
      :"userProcessFilter.scriptId" => :query,
      :"userProcessFilter.startTime" => :query,
      :"userProcessFilter.statuses" => :query,
      :"userProcessFilter.types" => :query,
      :"userProcessFilter.userAccessLevels" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/processes", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.Script.V1.Model.ListUserProcessesResponse{}])
  end

  @doc """
  List information about a script's executed processes, such as process type and current status.

  ## Parameters

  *   `connection` (*type:* `GoogleApi.Script.V1.Connection.t`) - Connection to server
  *   `optional_params` (*type:* `keyword()`) - Optional parameters
      *   `:"$.xgafv"` (*type:* `String.t`) - V1 error format.
      *   `:access_token` (*type:* `String.t`) - OAuth access token.
      *   `:alt` (*type:* `String.t`) - Data format for response.
      *   `:callback` (*type:* `String.t`) - JSONP
      *   `:fields` (*type:* `String.t`) - Selector specifying which fields to include in a partial response.
      *   `:key` (*type:* `String.t`) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
      *   `:oauth_token` (*type:* `String.t`) - OAuth 2.0 token for the current user.
      *   `:prettyPrint` (*type:* `boolean()`) - Returns response with indentations and line breaks.
      *   `:quotaUser` (*type:* `String.t`) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
      *   `:uploadType` (*type:* `String.t`) - Legacy upload protocol for media (e.g. "media", "multipart").
      *   `:upload_protocol` (*type:* `String.t`) - Upload protocol for media (e.g. "raw", "multipart").
      *   `:pageSize` (*type:* `integer()`) - The maximum number of returned processes per page of results. Defaults to 50.
      *   `:pageToken` (*type:* `String.t`) - The token for continuing a previous list request on the next page. This should be set to the value of `nextPageToken` from a previous response.
      *   `:scriptId` (*type:* `String.t`) - The script ID of the project whose processes are listed.
      *   `:"scriptProcessFilter.deploymentId"` (*type:* `String.t`) - Optional field used to limit returned processes to those originating from projects with a specific deployment ID.
      *   `:"scriptProcessFilter.endTime"` (*type:* `DateTime.t`) - Optional field used to limit returned processes to those that completed on or before the given timestamp.
      *   `:"scriptProcessFilter.functionName"` (*type:* `String.t`) - Optional field used to limit returned processes to those originating from a script function with the given function name.
      *   `:"scriptProcessFilter.startTime"` (*type:* `DateTime.t`) - Optional field used to limit returned processes to those that were started on or after the given timestamp.
      *   `:"scriptProcessFilter.statuses"` (*type:* `list(String.t)`) - Optional field used to limit returned processes to those having one of the specified process statuses.
      *   `:"scriptProcessFilter.types"` (*type:* `list(String.t)`) - Optional field used to limit returned processes to those having one of the specified process types.
      *   `:"scriptProcessFilter.userAccessLevels"` (*type:* `list(String.t)`) - Optional field used to limit returned processes to those having one of the specified user access levels.
  *   `opts` (*type:* `keyword()`) - Call options

  ## Returns

  *   `{:ok, %GoogleApi.Script.V1.Model.ListScriptProcessesResponse{}}` on success
  *   `{:error, info}` on failure
  """
  @spec script_processes_list_script_processes(Tesla.Env.client(), keyword(), keyword()) ::
          {:ok, GoogleApi.Script.V1.Model.ListScriptProcessesResponse.t()}
          | {:ok, Tesla.Env.t()}
          | {:ok, list()}
          | {:error, any()}
  def script_processes_list_script_processes(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :uploadType => :query,
      :upload_protocol => :query,
      :pageSize => :query,
      :pageToken => :query,
      :scriptId => :query,
      :"scriptProcessFilter.deploymentId" => :query,
      :"scriptProcessFilter.endTime" => :query,
      :"scriptProcessFilter.functionName" => :query,
      :"scriptProcessFilter.startTime" => :query,
      :"scriptProcessFilter.statuses" => :query,
      :"scriptProcessFilter.types" => :query,
      :"scriptProcessFilter.userAccessLevels" => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v1/processes:listScriptProcesses", %{})
      |> Request.add_optional_params(optional_params_config, optional_params)
      |> Request.library_version(@library_version)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.Script.V1.Model.ListScriptProcessesResponse{}])
  end
end
